package com.bupt.secret.constant;

/**
 * @desc 密码算法常量
 * @author shishumin
 * @date 2024/9/3 15:36
 */
public class AlgorithmConstants {
    // RSA PADDING
    public static final int RSA_SIGN_PADDING_MODE = 0; // RSA签名填充模式 (0)
    public static final int RSA_ENC_PADDING_MODE = 1; // RSA加密填充模式 (1)
    public static final int RSA_SIGN_BT = 0x01; // RSA签名类型 (1)
    public static final int RSA_ENC_BT = 0x02; // RSA加密类型 (2)

    // 临界值定义
    public static final int MAX_IV_LEN = 16; // 初始化向量的最大长度 (16)
    public static final int MAX_FILE_NAME_LEN = 32; // 文件名最大长度 (32)
    public static final int MIN_PIN_LEN = 8; // 最小的PIN长度 (8)
    public static final int MAX_PIN_LEN = 32; // 最大的PIN长度 (32)
    public static final int MAX_RSA_MODULUS_LEN = 256; // RSA算法模数的最大长度 (256)
    public static final int MAX_RSA_EXPONENT_LEN = 4; // RSA算法指数的最大长度 (4)

    public static final int ECC_MAX_XCOORDINATE_BITS_LEN = 256; // ECC算法X座标的最大长度 (256)
    public static final int ECC_MAX_YCOORDINATE_BITS_LEN = 256; // ECC算法Y座标的最大长度 (256)
    public static final int ECC_MAX_MODULUS_BITS_LEN = 256; // ECC算法模数的最大长度 (256)

    // 算法标识符
    public static final int SGD_SM1 = 0x00000100; // SM1算法 (256)
    public static final int SGD_SM1_ECB = 0x00000101; // SM1算法ECB加密模式 (257)
    public static final int SGD_SM1_CBC = 0x00000102; // SM1算法CBC加密模式 (258)
    public static final int SGD_SM1_CFB = 0x00000104; // SM1算法CFB加密模式 (260)
    public static final int SGD_SM1_OFB = 0x00000108; // SM1算法OFB加密模式 (264)
    public static final int SGD_SM1_MAC = 0x00000110; // SM1算法MAC运算 (272)
    public static final int SGD_SSF33 = 0x00000200; // SSF33算法 (512)
    public static final int SGD_SSF33_ECB = 0x00000201; // SSF33算法ECB加密模式 (513)
    public static final int SGD_SSF33_CBC = 0x00000202; // SSF33算法CBC加密模式 (514)
    public static final int SGD_SSF33_CFB = 0x00000204; // SSF33算法CFB加密模式 (516)
    public static final int SGD_SSF33_OFB = 0x00000208; // SSF33算法OFB加密模式 (520)
    public static final int SGD_SSF33_MAC = 0x00000210; // SSF33算法MAC运算 (528)
    public static final int SGD_SMS4 = 0x00000400; // SMS4算法 (1024)

    public static final int SGD_SMS4_ECB = 0x00000401; // SMS4算法ECB加密模式 (1025)
    public static final int SGD_SMS4_CBC = 0x00000402; // SMS4算法CBC加密模式 (1026)
    public static final int SGD_SMS4_CFB = 0x00000404; // SMS4算法CFB加密模式 (1028)
    public static final int SGD_SMS4_OFB = 0x00000408; // SMS4算法OFB加密模式 (1032)
    public static final int SGD_SMS4_MAC = 0x00000410; // SMS4算法MAC运算 (1040)
    public static final int SGD_SMS4_CTR = 0x00000412; // SMS4算法CTR加密模式 (1042)

    public static final int SGD_AES_ECB = 0x00000801; // AES算法ECB加密模式 (2049)
    public static final int SGD_AES_CBC = 0x00000802; // AES算法CBC加密模式 (2050)
    public static final int SGD_AES_CFB = 0x00000803; // AES算法CFB加密模式 (2051)
    public static final int SGD_AES_OFB = 0x00000804; // AES算法OFB加密模式 (2052)

    public static final int SGD_TDES3K_ECB = 0x00001001; // TDES3K (4097)
    public static final int SGD_TDES2K_ECB = 0x00002001; // TDES2K (8193)
    public static final int SGD_TDES_ECB = 0x00004001; // DES (16385)

    public static final int SGD_RSA = 0x00010000; // RSA算法 (65536)
    public static final int SGD_RSA_2048 = 0x00010800; // RSA 2048 (69888)
    public static final int SGD_ECC = 0x00020000; // ECC算法 (131072)
    public static final int SGD_SM2 = 0x00020100; // 椭圆曲线密码算法 (131328)
    public static final int SGD_SM2_1 = 0x00020200; // 椭圆曲线签名算法 (131584)
    public static final int SGD_SM2_2 = 0x00020400; // 椭圆曲线密钥交换协议 (131840)
    public static final int SGD_SM2_3 = 0x00020800; // 椭圆曲线加密算法 (132096)

    public static final int SGD_SM3 = 0x00000001; // SM3杂凑算法 (1)
    public static final int SGD_SHA1 = 0x00000002; // SHA1杂凑算法 (2)
    public static final int SGD_SHA256 = 0x00000004; // SHA256杂凑算法 (4)
    public static final int SGD_MD5 = 0x00000008; // MD5杂凑算法 (8)

    // 签名算法标识
    public static final int SGD_SM3_RSA = 0x00001001; // 基于SM3算法和RSA算法的签名 (4097)
    public static final int SGD_SHA1_RSA = 0x00001002; // 基于Sha1算法和RSA算法的签名 (4098)
    public static final int SGD_SHA256_RSA = 0x00001004; // 基于Sha256算法和RSA算法的签名 (4100)
    public static final int SGD_SM3_SM2 = 0x00020101; // 基于SM2算法和SM3算法的签名 (131329)

    // 密钥类型
    public static final int KT_PUBLIC_KEY = 0x01; // 公钥 (1)
    public static final int KT_PRIVATE_KEY = 0x02; // 私钥 (2)
    public static final int KT_SECRET_KEY = 0x03; // 密钥 (3)

    // 密钥应用类型
    public static final int AT_EXTERNAL_AUTHENTICATE_KEY = 0x00000001; // 用于设备对终端的认证 (1)

    // 权限类型
    public static final int SECURE_NEVER_ACCOUNT = 0x00000000; // 不允许 (0)
    public static final int SECURE_ADM_ACCOUNT = 0x00000001; // 管理员权限 (1)
    public static final int SECURE_USER_ACCOUNT = 0x00000010; // 用户权限 (16)
    public static final int SECURE_EVERYONE_ACCOUNT = 0x000000FF; // 任何人 (255)

    // PIN类型
    public static final int ADMIN_TYPE = 0; // 管理员PIN (0)
    public static final int USER_TYPE = 1; // 用户PIN (1)

    // 加密模式
    public static final int SGD_MODE_ECB = 0x00000001; // ECB加密模式 (1)
    public static final int SGD_MODE_CBC = 0x00000002; // CBC加密模式 (2)
    public static final int SGD_MODE_CFB = 0x00000004; // CFB加密模式 (4)
    public static final int SGD_MODE_OFB = 0x00000008; // OFB加密模式 (8)
    public static final int SGD_MODE_MAC = 0x00000010; // MAC运算 (16)

    // 密码最大重试次数
    public static final int MAX_PIN_TRY_COUNT = 0xF; // (15)
}